//////////////////////////////////////////////////////////////////////////////////
// Who  : Lim, Dong-moon (dmlim@nate.com, 011-701-9381)
// When : 2005/11/29
//////////////////////////////////////////////////////////////////////////////////

#ifndef __NCRYPT_PLAIN_BLOB_H__
#define __NCRYPT_PLAIN_BLOB_H__

#include <windows.h>
#include <wincrypt.h>
#include <stdio.h>
#ifdef _WIN32_WCE
#else
#include <crtdbg.h>
#endif
#include <tchar.h>

BOOL CreatePrivateExponentOneKey(HCRYPTPROV hProv,
                                 DWORD dwKeySpec,
                                 HCRYPTKEY *hPrivateKey);

BOOL CreatePrivateExponentOneKey(LPTSTR szProvider,
                                 DWORD dwProvType,
                                 LPTSTR szContainer,
                                 DWORD dwKeySpec,
                                 HCRYPTPROV *hProv,
                                 HCRYPTKEY *hPrivateKey);

BOOL GenerateSessionKeyWithAlgorithm(HCRYPTPROV hProv,
                                     ALG_ID Alg,
                                     HCRYPTKEY *hSessionKey);

BOOL DeriveSessionKeyWithAlgorithm(HCRYPTPROV hProv,
                                   ALG_ID Alg,
                                   LPBYTE lpHashingData,
                                   DWORD dwHashingData,
                                   HCRYPTKEY *hSessionKey);

BOOL ExportPlainSessionBlob(HCRYPTKEY hPublicKey,
                            HCRYPTKEY hSessionKey,
                            LPBYTE *pbKeyMaterial,
                            DWORD *dwKeyMaterial);

BOOL ImportPlainSessionBlob(HCRYPTPROV hProv,
                            HCRYPTKEY hPrivateKey,
                            ALG_ID dwAlgId,
                            LPBYTE pbKeyMaterial,
                            DWORD dwKeyMaterial,
                            HCRYPTKEY *hSessionKey);

#endif // __NCRYPT_PLAIN_BLOB_H__
